cmake_minimum_required(VERSION 3.5)

project(dal)

# To use std::thread in lib which is opened by dlopen, add this.
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

add_library(dal SHARED
    src/version.c
    src/comm_function.cpp
    src/allocator.c
    src/utils.c
    src/identifier.c
    src/string_sequence.c
    src/qos_policy.c)

target_link_libraries(dal PUBLIC dl Threads::Threads)
add_subdirectory(test)

install(TARGETS dal
        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/
        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

get_property( dal_version GLOBAL PROPERTY dal_version )
get_property( dal_version_major GLOBAL PROPERTY dal_version_major )
set_target_properties( dal PROPERTIES
    VERSION ${dal_version}
    SOVERSION ${dal_version_major})

target_compile_definitions(dal PRIVATE LIB_VERSION=\"Version:${dal_version}\")
